package net.hn.hnms.biz.project.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.project.request.ConstructionPlanReq;
import net.hn.hnms.biz.project.request.ConstructionTaskReq;
import net.hn.hnms.biz.project.service.IConstructionPlanService;
import net.hn.hnms.biz.project.service.IConstructionTaskService;
import net.hn.hnms.biz.project.vo.ConstructionPlanVo;
import net.hn.hnms.biz.project.vo.ConstructionTaskVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 刘昊
 * @date 2024-03-11 10:43
 */

@Api(value = "施工计划", tags = {"施工管理"})
@RestController
@RequestMapping("/constructionManagement/plan")
public class ConstructionPlanController extends BaseController {
    @Autowired
    private IConstructionPlanService constructionPlanService;

    @Autowired
    private IConstructionTaskService constructionTaskService;
    @ApiOperation("新增施工计划")
    @PostMapping("/add")
    @Log(title = "新增施工计划", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody ConstructionPlanReq req) {
        return constructionPlanService.insertReq(req);
    }

    @ApiOperation("删除施工计划")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除施工计划", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        return constructionPlanService.deleteList(idList);
    }

    @ApiOperation("修改施工计划")
    @PostMapping("/update")
    @Log(title = "修改施工计划", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody ConstructionPlanReq req) {
        return constructionPlanService.updateReq(req);
    }

//    @ApiOperation("查询施工计划")
//    @PostMapping("/selectPageList")
//    @AutoSetMineCode
//    @Log(title = "查询施工计划", businessType = BusinessType.UPDATE)
//    public R<ResponsePage<List<ConstructionPlanVo>>> selectPageList(@Validated @RequestBody ConstructionPlanReq req, PageQuery pageQuery) {
//        return constructionPlanService.selectPageList(req,pageQuery);
//    }


    @ApiOperation("查询施工计划")
    @PostMapping("/selectPageList")
    @AutoSetMineCode
    public R<ResponsePage<ConstructionPlanVo>> page(@RequestBody ConstructionPlanReq accidentInfoReq, PageQuery pageQuery) {
        return R.ok(constructionPlanService.selectPageList(accidentInfoReq, pageQuery));
    }

    @ApiOperation("查询施工任务详情")
    @SaCheckPermission("check:record:select")
    @PostMapping("/selectTaskList")
    @AutoSetMineCode
    @Log(title = "查询施工任务详情", businessType = BusinessType.UPDATE)
    public R<List<ConstructionTaskVo>> selectTaskList(@Validated @RequestBody ConstructionTaskReq req, PageQuery pageQuery) {
        return constructionTaskService.selectList(req);
    }

}
